package com.sky.financelake.viewmodels.remote;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.sky.financelake.bean.dto.StockDto;
import com.sky.financelake.retrofit.ApiResponse;
import com.sky.financelake.retrofit.StockRepository;
import com.sky.financelake.viewmodels.BaseViewModel;

public class StockDetailViewModel extends BaseViewModel {
    private MutableLiveData<ApiResponse<StockDto>> mutableLiveData;
    private StockRepository stockRepository;

    public StockDetailViewModel() {
        if (mutableLiveData != null) {
            return;
        }
        stockRepository = StockRepository.getInstance();
//        mutableLiveData = stockRepository.getStockByCode("000001");
    }

    public StockRepository getStockRepository() {
        return stockRepository;
    }

    public LiveData<ApiResponse<StockDto>> getStockDetailLiveData() {
        if (mutableLiveData == null) {
            mutableLiveData = new MutableLiveData<ApiResponse<StockDto>>();
        }
        return mutableLiveData;
    }


    public void getStockByCode(String code) {
        stockRepository.getStockByCode(mutableLiveData, code);
    }
}
